package com.sfjswl.fp.core.leaf.base;

import com.sfjswl.fp.common.enums.NodeRunStateEnum;
import com.sfjswl.fp.core.base.BaseLeaf;
import com.sfjswl.fp.core.context.RuleContext;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public abstract class BaseLeafResult extends BaseLeaf {

  @Override
  protected NodeRunStateEnum doLeaf(RuleContext ctx) {
    if (this.doResult(ctx)) {
      return NodeRunStateEnum.TRUE;
    }
    return NodeRunStateEnum.FALSE;
  }

  protected abstract boolean doResult(RuleContext ctx);
}
